from models.swiper import Swiper
from models import db
class SwiperRepo:
    @staticmethod
    def find_all():
        data = Swiper.query.all()
        return  data

    @staticmethod
    def find_by_id(id):
        data = Swiper.query.get(id)
        return  data if data else None

    @staticmethod
    def delete_by_id(id):
        swiper = Swiper.query.get(id)
        if swiper:
            db.session.delete(swiper)
            db.session.commit()


    @staticmethod
    def insert(swiper):
        data = Swiper(**swiper)
        db.session.add(data)
        db.session.commit()
